//
// Created by Administrator on 2024/4/9.
//
#include<bits/stdc++.h>

using namespace std;
const int BOMB = 999;

int main() {
    int n, m, k, x, y;
    int fx[][2] = {0, 1, 0, -1, 1, 0, -1, 0, -1, -1, 1, -1, -1, 1, 1, 1};//八连通
    while (cin >> n >> m >> k) {
        vector<vector<int>> v(n, vector<int>(m, 0));
        while (k--) {
            cin >> x >> y;
            v[x][y] = BOMB;
        }
        for (x = 0; x < n; x++) {
            for (y = 0; y < m; y++) {
                if (v[x][y] == BOMB)continue;
                int &cnt = v[x][y];
                for (int i = 0; i < 8; i++) {
                    int nx = x + fx[i][0];
                    int ny = y + fx[i][1];
                    if (nx < 0 || nx >= n || ny < 0 || ny >= m)continue;
                    if (v[nx][ny] == BOMB)++cnt;

                }

            }
        }
        for (x = 0; x < n; x++) {
            for (y = 0; y < m; y++) {
                if (v[x][y] == BOMB)cout << "*";
                else
                    cout << v[x][y];
            }
            cout << endl;
        }
        cout << endl;

    }

    return 0;
}